﻿@model EDB.SmoothStreaming.ViewModels.VideoEditViewModel

@{
    Style.Require("EDBSmoothStreaming");
    Script.Require("EDBSmoothStreaming").AtHead();
}

<fieldset>
    <div class="VideoSettings">
        @Html.CheckBoxFor(m => m.ExtractCompressedFile) 
        <label for="@Html.FieldIdFor(m => m.ExtractCompressedFile)" class="forcheckbox">@T("Extract Compressed File")</label>

        <label for="VideoPath">@T("Video Path")</label>
        <input id="VideoPath" name="VideoPath" type="file" value="@T("Browse")" />
        <br />
        <br />

        @Html.LabelFor(m => m.ThumbnailFormat, T("Thumbnail Format"))
        @foreach (EDB.SmoothStreaming.Models.ThumbnailFormat value in Enum.GetValues(typeof(EDB.SmoothStreaming.Models.ThumbnailFormat))) {
            string isChecked = Model.ThumbnailFormat == value ? "checked=\"checked\"" : "";
            <input id="@value.ToString()" name="@Html.FieldNameFor(m => m.ThumbnailFormat)" type="radio" value="@value.ToString()" @isChecked />
            <label for="@value.ToString()" class="forcheckbox">@value.ToString()</label> 
        }
        <div class="Settings">
            @Html.LabelFor(m => m.ThumbnailWidth, T("Thumbnail Width"))
            @Html.TextBoxFor(m => m.ThumbnailWidth, new { @class = "text" })

            @Html.LabelFor(m => m.ThumbnailHeight, T("Thumbnail Height"))
            @Html.TextBoxFor(m => m.ThumbnailHeight, new { @class = "text" })

            @Html.LabelFor(m => m.ThumbnailCount, T("Thumbnail Count"))
            @Html.TextBoxFor(m => m.ThumbnailCount, new { @class = "text" })

            <br /><br />

            @Html.HiddenFor(m => m.VideoStreams)
            <div class="VideoStreamsHeader"><span>@T("Stream")</span><span>@T("Width")</span><span>@T("Height")</span><span>@T("Bitrate")</span><div style="clear:both;"></div></div>
            <div id="VideoStreamsContainer" class="VideoStreams"></div>
            <div><a href="javascript:AddStream()">@T("add")</a></div>
        </div>

        <br />

        @Html.LabelFor(m => m.PlayerWidth, T("Player Width"))
        @Html.TextBoxFor(m => m.PlayerWidth, new { @class = "text" })

        @Html.LabelFor(m => m.PlayerHeight, T("Player Height"))
        @Html.TextBoxFor(m => m.PlayerHeight, new { @class = "text" })
    </div>

    @if (Model.VideoId != Guid.Empty) {
    <div class="VideoPreview">
        @T("Preview Video")<br />
        <object class="VideoPlayer" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="480" height="310">
            <param name="source" value="@Url.Content("~/Modules/EDB.SmoothStreaming/Content/SmoothStreamingPlayer.xap")"/>
            <param name="background" value="#000000" />
            <param name="minRuntimeVersion" value="4.0.50303.0" />
            <param name="autoUpgrade" value="true" />
            <param name="windowless" value="true" />
            <param name="InitParams" value="stretchmode=Fill,continuousplay=true,autoplay=False,MediaUrl=@Model.VideoFolderPath/ss.ism/manifest,DeliveryMethod=AdaptiveStreaming" />
            <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50303.0" style="text-decoration:none">
                <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
            </a>
        </object>
    </div>
    }
    <div style="clear:both;"></div>
</fieldset>

@using (Script.Foot()) {
<script type="text/javascript">
//<![CDATA[
    $('#content form')
        .attr('enctype', 'multipart/form-data')
        .attr('encoding', 'multipart/form-data');

    $(function () {
        $('#@Html.FieldIdFor(m => m.ExtractCompressedFile)').change(function () {
            if ($(this).is(':checked')) {
                $('.VideoSettings .Settings').slideUp();
                $('label[for=VideoPath]').text('@T("Compressed File Path")');
            }
            else {
                $('.VideoSettings .Settings').slideDown();
                $('label[for=VideoPath]').text('@T("Video Path")');
            }
        });

        VideoInit('@Html.FieldIdFor(m => m.VideoStreams)');
    });
//]]>
</script>
}